package com.hlbbcsr.business.impl;

import java.util.List;

import com.hlbbcsr.business.AccountManager;
import com.hlbbcsr.domain.bean.Customer;

public class AccountManagerImpl extends BaseManager implements
		AccountManager {

	public Customer getCustomerByLoginId(String loginId) throws Exception {

		List<Customer> customerList = getCustomerDAO().findByLoginId(loginId);
		return (customerList != null)? customerList.get(0): null;

	}
	
	public List<Customer> listCustomer() throws Exception {

		return getCustomerDAO().listCgsCustomer();

	}

	/**
	 * Add Customer
	 */
	public void addCustomer(Customer customer) throws Exception {
		if (customer != null) {
			
			// MD5 password
			customer.setPassword(encodeString(customer.getPassword()));
			
			// Call DAO layer to insert customer into database
			getCustomerDAO().addCustomer(customer);
		}		
	}
	
};